﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="MensUnoShop.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	HanselSetup
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<style>
    table#coupon td{border:1px solid #ccc;}
    tr#memo:hover th,tr#memo2:hover th {background-color:#E6E6E6;}
    tr#memo:hover td,tr#memo2:hover td  {	background-color:#FFFFFF;}
    tr#memo:hover td tr#memo1 td,tr#memo2:hover td tr#memo3 td{background-color:#E6E6E6;}
</style>
<%
    var saleskit = ViewData["saleskit"] as USalesKit;
%>
<div id="main-content" class="hastable">
    <div class="title title-spacing">
	    <h2>合購活動管理</h2>
    </div>
<form action="" method="post">
    <input type="hidden" name="Act" value="<%:ViewData["Act"] %>">
    <input type="hidden" name="tagid" value="<%:saleskit==null?"":saleskit.SStagid %>">
<table id="coupon" style="width:1000px;">
<tr>
    <th width="90">活動(標籤)名稱</th><td><input type="text" size="20" name="stitle" value="<%:saleskit==null?"":saleskit.SStitle %>" /></td>
</tr>
<tr>
    <th>活動期間</th>
    <td>
        <input class="datepicker" name="startdate" type="text" id="startdate" size="10" readonly="readonly" value="<%:saleskit==null?"":saleskit.SSstartdate.Value.ToShortDateString() %>" />
        <input class="datepicker" name="enddate" type="text" id="enddate" size="10" readonly="readonly" value="<%:saleskit==null?"":saleskit.SSenddate.Value.ToShortDateString() %>" />
    </td>
</tr>
<tr>
    <th>活動資格</th>
    <td>
        <input name="pices" type="text" id="pices" size="2" value="<%:saleskit==null?"":saleskit.SSnote.Split('|')[0] %>" />件，
        <input name="comboprice" type="text" id="comboprice" size="6" value="<%:saleskit==null?"":saleskit.SSnote.Split('|')[1] %>" />元
    </td>
</tr>
<%if(saleskit != null){ %>
<tr id="memo">
    <th>合購商品</th>
    <td>
        
        <table cellspacing="0" style="width:800px;">
            <thead>
				<tr id="memo1">
					<td style="width:400px">商品清單</td>
					<td style="width:400px">已挑選清單</td>
				</tr>
			</thead>
             <tbody>
				<tr>
					<td style="width:400px;">
                        快速搜尋：<input type="text" id="search" onkeyup="searchMarketList();" />
                        <select id="outlist" name="outlist" multiple="multiple" style="width:400px;height:600px">
                            <option>讀取中...</option>
                        </select>
                    </td>
					<td style="width:400px; vertical-align:top;">
                        <select id="inlist" name="inlist" multiple="multiple" style="width:400px;height:600px;margin-top:25px;">
                            <option>讀取中...</option>
                        </select>
                    </td>
				</tr>
                <tr>
					<td style="width:400px; vertical-align:top;">
                        <input type="button" value="加入>>>" onclick="setin()" />
                    </td>
					<td style="width:400px; vertical-align:top;">
                        <input type="button" value="<<<取消" onclick="setout()" />
                    </td>
				</tr>
            </tbody>
         </table>
    </td>
</tr>
<tr id="memo2">
    <th>活動類別</th>
    <td>
        <table cellspacing="0" style="width:800px;">
            <thead>
				<tr id="memo3">
					<td style="width:400px">主類別清單</td>
					<td style="width:400px">已挑選清單</td>
				</tr>
			</thead>
             <tbody>
				<tr>
					<td style="width:400px; vertical-align:top;">
                        <select id="tagoutlist" name="tagoutlist" multiple="multiple" style="width:400px;height:200px">
                            <option>讀取中...</option>
                        </select>
                    </td>
					<td style="width:400px; vertical-align:top;">
                        <select id="taginlist" name="taginlist" multiple="multiple" style="width:400px;height:200px">
                            <option>讀取中...</option>
                        </select>
                    </td>
				</tr>
                <tr>
					<td style="width:400px; vertical-align:top;">
                        <input type="button" value="加入>>>" onclick="settagin()" />
                    </td>
					<td style="width:400px; vertical-align:top;">
                        <input type="button" value="<<<取消" onclick="settagout()" />
                    </td>
				</tr>
            </tbody>
            </table>
    </td>
</tr>
<%} %>
<tr><td colspan="2"><input type="submit" value="<%:ViewData["title"] %>" /></td></tr>
</table>
</form>

</div>
<div id="bkm" style="width:100%;height:1000px;position:fixed; top:0px; left:0px;background-color:Black;z-index:999999;filter:alpha(opacity=50);-moz-opacity:0.5;opacity: 0.5;"></div>
<div id="bkt" style="width:100%;height:1000px;position:fixed; top:0px; left:0px;background-color:Black;z-index:999999;filter:alpha(opacity=50);-moz-opacity:0.5;opacity: 0.5;"></div>

<script type="text/javascript">
$("#bkm").hide();
$("#bkt").hide();
<%if(saleskit!=null){ %>
    $("#bkm").show();
    $.ajax({
        type: "POST",
        traditional: true,
        cache: false,
        url: "/Admin/TagSetup/api_choice/<%:saleskit.SStagid %>",
        dataType: "json",
        success: function (data) {
            if (data.code == "200") {
                $("#outlist option").remove();
                $("#inlist option").remove();
                 for (var i = 0; i < data.outlist.title.length; i++) {
                     $("#outlist").append('<option value="' + data.outlist.mkguid[i] + '">' + data.outlist.title[i] + '</option>');
                 }
                 for (var i = 0; i < data.inlist.title.length; i++) {
                     $("#inlist").append('<option value="' + data.inlist.mkguid[i] + '">' + data.inlist.title[i] + '</option>');
                 }
             }
             else
                 alert(data.response);
             $("#bkm").hide();
        }
    });
    $("#bkt").show();
            $.ajax({
                type: "GET",
                traditional: true,
                url: "/Admin/TagSetup/api_appoint/<%:saleskit.SStagid  %>",
                cache: false,
                dataType: "json",
                success: function (data) {
                    if (data.code == "200") {
                        $("#tagoutlist option").remove();
                        $("#taginlist option").remove();
                        for (var i = 0; i < data.outlist.title.length; i++) {
                            $("#tagoutlist").append('<option value="' + data.outlist.mkguid[i] + '">' + data.outlist.title[i] + '</option>');
                        }
                        for (var i = 0; i < data.inlist.title.length; i++) {
                            $("#taginlist").append('<option value="' + data.inlist.mkguid[i] + '">' + data.inlist.title[i] + '</option>');
                        }
                    }
                    else
                        alert(data.response);
                    $("#bkt").hide();
                }
            });
            

            function settagin() {
                var json = { "mklist": [$("#tagoutlist").val()] };
                $("#bkt").show();
                $.ajax({
                    type: "POST",
                    traditional: true,
                    url: "/Admin/TagSetup/api_appointsetin/<%:saleskit.SStagid %>",
                    cache: false,
                    data: json,
                    dataType: "json",
                    success: function (data) {
                        if (data.code == "200") {
                            $("#tagoutlist option").remove();
                            $("#taginlist option").remove();
                            for (var i = 0; i < data.outlist.title.length; i++) {
                                $("#tagoutlist").append('<option value="' + data.outlist.mkguid[i] + '">' + data.outlist.title[i] + '</option>');
                            }
                            for (var i = 0; i < data.inlist.title.length; i++) {
                                $("#taginlist").append('<option value="' + data.inlist.mkguid[i] + '">' + data.inlist.title[i] + '</option>');
                            }
                        }
                        else
                            alert(data.response);
                         $("#bkt").hide();
                    }
                });
               
            }

            function settagout() {
                $("#bkt").show();
                var json = { "mklist": [$("#taginlist").val()] };
                $.ajax({
                    type: "POST",
                    traditional: true,
                    url: "/Admin/TagSetup/api_appointsetout/<%:saleskit.SStagid %>",
                    cache: false,
                    data: json,
                    dataType: "json",
                    success: function (data) {
                        if (data.code == "200") {
                            $("#tagoutlist option").remove();
                            $("#taginlist option").remove();
                            for (var i = 0; i < data.outlist.title.length; i++) {
                                $("#tagoutlist").append('<option value="' + data.outlist.mkguid[i] + '">' + data.outlist.title[i] + '</option>');
                            }
                            for (var i = 0; i < data.inlist.title.length; i++) {
                                $("#taginlist").append('<option value="' + data.inlist.mkguid[i] + '">' + data.inlist.title[i] + '</option>');
                            }
                        }
                        else
                            alert(data.response);
                             $("#bkt").hide();
                    }
                });
            }
 

             function setin() {
                 var json = { "mklist": [$("#outlist").val()] };
                 $("#bkm").show();
                 $.ajax({
                     type: "POST",
                     traditional: true,
                     url: "/Admin/TagSetup/api_choicesetin/<%:saleskit.SStagid %>",
                     cache: false,
                     data: json,
                     dataType: "json",
                     success: function (data) {
                         if (data.code == "200") {
                             $("#outlist option").remove();
                             $("#inlist option").remove();
                             for (var i = 0; i < data.outlist.title.length; i++) {
                                 $("#outlist").append('<option value="' + data.outlist.mkguid[i] + '">' + data.outlist.title[i] + '</option>');
                             }
                             for (var i = 0; i < data.inlist.title.length; i++) {
                                 $("#inlist").append('<option value="' + data.inlist.mkguid[i] + '">' + data.inlist.title[i] + '</option>');
                             }
                         }
                         else
                             alert(data.response);
                          $("#bkm").hide();
                     }
                 });
             }

             function setout() {
                 $("#bkm").show();
                 var json = { "mklist": [$("#inlist").val()] };
                 $.ajax({
                     type: "POST",
                     traditional: true,
                     url: "/Admin/TagSetup/api_choicesetout/<%:saleskit.SStagid %>",
                     cache: false,
                     data: json,
                     dataType: "json",
                     success: function (data) {
                         if (data.code == "200") {
                             $("#outlist option").remove();
                             $("#inlist option").remove();
                             for (var i = 0; i < data.outlist.title.length; i++) {
                                 $("#outlist").append('<option value="' + data.outlist.mkguid[i] + '">' + data.outlist.title[i] + '</option>');
                             }
                             for (var i = 0; i < data.inlist.title.length; i++) {
                                 $("#inlist").append('<option value="' + data.inlist.mkguid[i] + '">' + data.inlist.title[i] + '</option>');
                             }
                         }
                         else
                             alert(data.response);
                              $("#bkm").hide();
                     }
                 });
             }

            function searchMarketList(){
                $("#bk").show();
                var json = { "mksn": $("#search").val() };
                $.ajax({
                    type: "POST",
                    traditional: true,
                    url: "/Admin/TagSetup/api_choice_search/<%:saleskit.SStagid %>",
                    data: json,
                    dataType: "json",
                    success: function (data) {
                        if (data.code == "200") {
                            $("#outlist option").remove();
                            $("#inlist option").remove();
                            for (var i = 0; i < data.outlist.title.length; i++) {
                                $("#outlist").append('<option value="' + data.outlist.mkguid[i] + '">' + data.outlist.title[i] + '</option>');
                            }
                            for (var i = 0; i < data.inlist.title.length; i++) {
                                $("#inlist").append('<option value="' + data.inlist.mkguid[i] + '">' + data.inlist.title[i] + '</option>');
                            }
                        }
                        else
                            alert(data.response);
                        $("#bk").hide();
                    }
                });
            }
    <%} %>

</script>


</asp:Content>
